//TODO: Move the procedures in this file into an update script for stats
var combatant = argument8;

var vit = argument0;
var physStr = argument1;
var physDef = argument2;
var spd = argument3;
var specStr = argument4;
var specDef = argument5;
var luck = argument6;
var align = argument7;

//Constants
var POINTS_MULTIPLIER = 10;

//Flat damage applied without a weapon
var MAX_BASE_DAMAGE = 125;

//Percentage of damage absorbed when attacked
//Applied after flat damage reduction by armor
var MAX_BASE_ATK_DEFENSE = .6;
var MAX_BASE_SPEC_DEFENSE = .7;

var MIN_MOVE_SPEED = 5;
var MAX_MISC_SPEED = .5;

combatant.stats [STATS.VITALITY] = vit;
combatant.stats [STATS.PHYS_STR] = physStr;
combatant.stats [STATS.PHYS_DEF] = physDef;
combatant.stats [STATS.SPEED] = spd;
combatant.stats [STATS.SPEC_STR] = specStr;
combatant.stats [STATS.SPEC_DEF] = specDef;
combatant.stats [STATS.LUCK] = luck;
combatant.alignment = align;

//From the formulas on the stats design doc
combatant.HPMax = POINTS_MULTIPLIER * vit;
combatant.HPCurrent = combatant.HPMax;

combatant.SPMax = POINTS_MULTIPLIER * specStr;
combatant.SPCurrent = combatant.SPMax;

combatant.attackBonus = ( physStr / 255 ) * MAX_BASE_DAMAGE;
combatant.attackDefense = ( physDef / 255 ) * MAX_BASE_ATK_DEFENSE;

combatant.specialDef = ( specDef / 255 ) * MAX_BASE_SPEC_DEFENSE;

//Range from 1 to 2. Meant to be multiplied to the weapon speed
combatant.atkSpdMod = ( 1 + ( spd / 255 ) );

//Overrides the move speed in gameObject
//Range from MIN_MOVE_SPEED to 2 * MIN_MOVE_SPEED
combatant.moveSpeed  = MIN_MOVE_SPEED * ( 1 + ( spd / 255 ) );

combatant.miscSpdMod = ( spd / 255 ) * MAX_MISC_SPEED;

//TODO: Fix the luckMod [needs verification]
combatant.luckMod = (luck / 255);

return combatant;